/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Ordenes.java
 *
 * Created on 13-nov-2011, 12:53:29
 */
package IGU;

import com.sun.awt.AWTUtilities;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

/**
 *
 * @author luisramirezmartinez
 */
public final class Ordenes extends javax.swing.JFrame {

    /** Creates new form Ordenes */
    public Ordenes() {
        setUndecorated(true);
        setResizable(false);
        AWTUtilities.setWindowOpaque(this, false);
        initComponents();
          dataSource1.consulta();
          dataSource2.consulta();
          dataSource3.consulta();
       
       this.titleBar1.addCloseAction(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                dispose();
            }
        });
       this.Refresh();
    }

    
    
    
     public void Refresh()
     {
         Timer timer = new Timer (8000, new ActionListener ()
         {
            @Override
             public void actionPerformed(ActionEvent e) {
                 System.out.println("actualizo");
                 dataSource1.consulta();
                 dataSource2.consulta();
                 dataSource3.consulta();
             }
         });
         timer.start();
     }
     

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dataSource1 = new FuenteDeDatos.DataSource();
        dataSource2 = new FuenteDeDatos.DataSource();
        dataSource3 = new FuenteDeDatos.DataSource();
        panelNice1 = new org.edisoncor.gui.panel.PanelNice();
        titleBar1 = new org.edisoncor.gui.varios.TitleBar();
        jScrollPane1 = new javax.swing.JScrollPane();
        dataTable1 = new FuenteDeDatos.DataTable();
        jScrollPane2 = new javax.swing.JScrollPane();
        dataTable2 = new FuenteDeDatos.DataTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        dataTable3 = new FuenteDeDatos.DataTable();

        dataSource1.setCodigosql("select Id_orden as \"Nº Orden\", Nombre as \"Platillo\",  Descripcion as \"Descripción\", cantidad as \"Cantidad\" from tbl_orden join tbl_det_Orden using (Id_Orden)   join tbl_platillos_bebida using(Id_platillo)  where  Id_orden=(select max(Id_orden) from tbl_orden);");
        dataSource1.setDb("u164902_SARB");
        dataSource1.setIp("192.168.1.103:3306");
        dataSource1.setPassword("1234");
        dataSource1.setUsuario("orland");

        dataSource2.setCodigosql("select Id_orden as \"Nº Orden\", Nombre as \"Platillo\", \nDescripcion as \"Descripción\", cantidad as \"Cantidad\"\nfrom tbl_orden join tbl_det_Orden using (Id_Orden)  \njoin tbl_platillos_bebida using(Id_platillo) \nwhere  Id_orden=(select max(Id_orden)-1\nfrom tbl_orden);");
        dataSource2.setDb("u164902_SARB");
        dataSource2.setIp("192.168.1.103:3306");
        dataSource2.setPassword("1234");
        dataSource2.setUsuario("orland");

        dataSource3.setCodigosql("select Id_orden as \"Nº Orden\", Nombre as \"Platillo\", \nDescripcion as \"Descripción\", cantidad as \"Cantidad\"\nfrom tbl_orden join tbl_det_Orden using (Id_Orden)  \njoin tbl_platillos_bebida using(Id_platillo) \nwhere  Id_orden=(select max(Id_orden)-2\nfrom tbl_orden);");
        dataSource3.setDb("u164902_SARB");
        dataSource3.setIp("192.168.1.103:3306");
        dataSource3.setPassword("1234");
        dataSource3.setUsuario("orland");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        titleBar1.setTitulo("Ordenes en Proceso");
        titleBar1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                titleBar1MouseClicked(evt);
            }
        });

        dataTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        dataTable1.setData(dataSource1);
        jScrollPane1.setViewportView(dataTable1);

        dataTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        dataTable2.setData(dataSource3);
        jScrollPane2.setViewportView(dataTable2);

        dataTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        dataTable3.setData(dataSource2);
        jScrollPane3.setViewportView(dataTable3);

        org.jdesktop.layout.GroupLayout panelNice1Layout = new org.jdesktop.layout.GroupLayout(panelNice1);
        panelNice1.setLayout(panelNice1Layout);
        panelNice1Layout.setHorizontalGroup(
            panelNice1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(titleBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
            .add(panelNice1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 740, Short.MAX_VALUE)
                .addContainerGap())
            .add(panelNice1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 740, Short.MAX_VALUE)
                .addContainerGap())
            .add(panelNice1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 740, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelNice1Layout.setVerticalGroup(
            panelNice1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelNice1Layout.createSequentialGroup()
                .add(titleBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 175, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 191, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 191, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelNice1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelNice1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void titleBar1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_titleBar1MouseClicked

    }//GEN-LAST:event_titleBar1MouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Ordenes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new Ordenes().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private FuenteDeDatos.DataSource dataSource1;
    private FuenteDeDatos.DataSource dataSource2;
    private FuenteDeDatos.DataSource dataSource3;
    private FuenteDeDatos.DataTable dataTable1;
    private FuenteDeDatos.DataTable dataTable2;
    private FuenteDeDatos.DataTable dataTable3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private org.edisoncor.gui.panel.PanelNice panelNice1;
    private org.edisoncor.gui.varios.TitleBar titleBar1;
    // End of variables declaration//GEN-END:variables

}
